package com.test.anno;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created on 2016/7/13.
 */
public class UseCaseTracker {
    public static void trackUseCases(List<Integer> useCases, Class<?> cl) {
        for (Method m : cl.getDeclaredMethods()) {
            UseCase uc = m.getAnnotation(UseCase.class);
            if (uc != null) {
                System.out.println(String.format("Found Use Case:%s, %s", uc.id(), uc.description()));
                useCases.remove(uc.id());
            }
        }
        for (int i : useCases) {
            System.out.println("Warning: Missing use case-" + i);
        }
    }

    public static void main(String[] args) {
        ArrayList<Integer> useCases = new ArrayList<Integer>();
        Collections.addAll(useCases, 1, 2, 3, 4);
        trackUseCases(useCases, A.class);
    }
}

class A {
    @UseCase(id = 3)
    private void a1() {
    }

}
